<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>蓝源Eloan-P2P平台(系统管理平台)</title>
	<#include "../common/header.ftl"/>
	<script type="text/javascript" src="/js/plugins/jquery.form.js"></script>
	<script type="text/javascript" src="/js/plugins/jquery-validation/jquery.validate.js"></script>
	<script type="text/javascript" src="/js/plugins/jquery.twbsPagination.min.js"></script>
	
	<script type="text/javascript">
		$(function() {
            $('#pagination').twbsPagination({
				visiblePages: 5,
				startPage:${pageInfo.pageNum},
				totalPages:${pageInfo.pages} || 1,
				onPageClick: function (event, page) {
					$("#pageNum").val(page);
					$("#searchForm").submit();
				},
				first:"首页" ,
				prev:"上页" ,
				next:"下页" ,
				last:"尾页"
		    });
			//添加数据字典数据
			$("#addSystemDictionaryBtn").click(function () {
			    //打开模态框之前清楚表单信息
                $("#editForm").clearForm();
				$("#systemDictionaryModal").modal('show');
            });
			$("#saveBtn").click(function(){
			    //发送请求到后台
				$("#editForm").ajaxSubmit({
					dataType: 'json',
					success:function (data) {
						if(data.success){
						    $.messager.confirm("温馨提示",data.msg,function () {
                                //刷新界面
                                location.reload();
                            })
						}else {
							//弹出警告信息
							$.messager.popup(data.msg)
						}
                    }
				})
			});
			//修改按钮
			$(".edit_Btn").click(function () {
                //打开模态框之前清楚表单信息
                $("#editForm").clearForm();
                $("#systemDictionaryModal").modal('show');
                //获取其json数据
				//使用自定义属性的好处是 :如果是json字符串类型 自动的把json字符串转换成json对象
				//如果不是自定义属性的话 传过来的是什么就是什么
                var data = $(this).data('json')
				//回填数据到弹出框
				$("#systemDictionaryId").val(data.id);
                $("#title").val(data.title);
                $("#sn").val(data.sn);
            });
			//高级查询按钮
			$("#query").click(function () {
			    $("#pageNum").val(1);
				$("#searchForm").submit();
            })
		});
	</script>
</head>

<body>
	<div class="container">
		<#include "../common/top.ftl"/>
		<div class="row">
			<div class="col-sm-3">
				<#assign currentMenu = "systemDictionary" />
				<#include "../common/menu.ftl" />
			</div>
			<div class="col-sm-9">
				<div class="page-header">
					<h3>数据字典管理</h3>
				</div>
				<div class="row">
					<!-- 提交分页的表单 -->
					<form id="searchForm" class="form-inline" method="post" action="/systemDictionary_list">
						<input type="hidden" name="pageNum" id="pageNum" value="${qo.pageNum}"/>
						<div class="form-group">
						</div>
						<div class="form-group">
						    <label>关键字</label>
						    <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!''}">
						</div>
						<div class="form-group">
							<button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
							<a href="javascript:void(-1);" class="btn btn-success" id="addSystemDictionaryBtn">添加数据字典</a>
						</div>
					</form>
				</div>
				<div class="row">
					<table class="table">
						<thead>
							<tr>
								<th>名称</th>
								<th>编码</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
						<#list pageInfo.list as vo>
							<tr>
								<td>${vo.title}</td>
								<td>${vo.sn}</td>
								<td>
									<a href="javascript:void(-1);" data-json='${vo.jsonstring}' class="edit_Btn">修改</a>
								</td>
							</tr>
						</#list>
						</tbody>
					</table>
					
					<div style="text-align: center;">
						<ul id="pagination" class="pagination"></ul>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div id="systemDictionaryModal" class="modal" tabindex="-1" role="dialog">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title">编辑/增加</h4>
	      </div>
	      <div class="modal-body">
	      		<form id="editForm" class="form-horizontal" method="post" action="/systemDictionary_update" style="margin: -3px 118px">
			    <input id="systemDictionaryId" type="hidden" name="id" value="" />
			   	<div class="form-group">
				    <label class="col-sm-2 control-label">名称</label>
				    <div class="col-sm-6">
				    	<input type="text" class="form-control" id="title" name="title" placeholder="字典分类名称">
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">编码</label>
				    <div class="col-sm-6">
				    	<input type="text" class="form-control" id="sn" name="sn" placeholder="字典分类编码">
				    </div>
				</div>
		   </form>
		  </div>
	      <div class="modal-footer">
	      	<a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
		    <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
	      </div>
	    </div>
	  </div>
	</div>
</body>
</html>